/*
 * @Author: your name
 * @Date: 2020-07-28 22:56:49
 * @LastEditTime: 2020-07-28 23:27:22
 * @LastEditors: Please set LastEditors
 * @Description: In User Settings Edit
 * @FilePath: \react-hooks-app\src\demo\btns.js
 */

 import React, { useContext } from 'react';

 import {UPDATE_COLOR,ColorContext} from './colorState'

 function Btns(){

  let colorState = useContext(ColorContext);

  return(
    <div>
      <button onClick={()=>{colorState.dispatch({type:UPDATE_COLOR,color:'red'})}}>红色</button>
      <button onClick={()=>{colorState.dispatch({type:UPDATE_COLOR,color:'yellow'})}}>黄色</button>
    </div>
  )
 }

 export default Btns;
